package com.daiqile.okgodemo.adapter;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.blankj.utilcode.util.Utils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.daiqile.okgodemo.base.Constants;
import com.daiqile.okgodemo.R;
import com.daiqile.okgodemo.model.MainItemList;

import java.util.Collection;
import java.util.List;

/**
 * @author Mr.Bean
 * @date Created on 2017/10/16.
 */

public class MainItemAdapter extends BaseQuickAdapter<MainItemList.DataBean,BaseViewHolder>{
    public MainItemAdapter(@Nullable List<MainItemList.DataBean> data) {
        super(R.layout.item_mainitem, data);
    }



    @Override
    public void addData(@NonNull Collection<? extends MainItemList.DataBean> newData) {
        super.addData(newData);
    }

    @Override
    protected void convert(BaseViewHolder helper, MainItemList.DataBean item) {
        String url = Constants.BASE_URL_IMG + item.getImg();
        Glide.with(Utils.getContext())
                .load(url)
                .error(R.drawable.imgerror)
                .into((ImageView)helper.getView(R.id.mi_img));

        helper
                .setText(R.id.mi_t1,item.getApp_name())
                .setText(R.id.mi_t2,item.getContent())
                .setText(R.id.mi_t3,item.getApplied())
                .setText(R.id.mi_t4,item.getMin()+"~"+item.getMax());



    }
}
